package com.xiaojiang.dto;

import com.xiaojiang.entity.AccessType;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 功能：
 * 作者：小江
 * 日期：2024年10月26日
 */
@Data
public class QueryCarRecordsDto {
    private Integer carRecordId;
    private String carLicensePlate;
    private LocalDateTime accessTime;
    private AccessType accessType;

    private Integer currentPage;
    private Integer pageSize;
    private Integer startIndex;

    public QueryCarRecordsDto(){
        this.currentPage = 1; // 默认第一页
        this.pageSize = 8;  // 默认每页10条记录
    }

    public Integer getStartIndex() {
        if (this.currentPage == null || this.pageSize == null) {
            throw new IllegalArgumentException("currentPage or pageSize cannot be null");
        }
        return (this.currentPage - 1) * this.pageSize;
    }
}
